package com.pac.weixin.controller;

import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.common.util.MsgKeyContent;
import com.pac.weixin.bean.WxPopularizeBean;
import com.pac.weixin.service.WxPopularizeService;

/**
 * 微信推广controller
 * 
 * @author lujun.chen
 * @version [版本号, 2015年3月5日]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
@Controller
@Scope("prototype")
@RequestMapping("/weixin/popularize")
public class WxPopularizeController {

	private static Logger logger = Logger
			.getLogger(WxPopularizeController.class);

	@Autowired
	private WxPopularizeService wxPopularizeService;

	/**
	 * <一句话功能简述> <功能详细描述>
	 * 
	 * @return
	 * @see [类、类#方法、类#成员]
	 */
	@RequestMapping("/access")
	@ResponseBody
	public Map<String, Object> accessPopularize(
			WxPopularizeBean wxPopularizeBean) {
		boolean result = true;
		String msg = "";

		try {
			wxPopularizeService.addPopularize(wxPopularizeBean);
		} catch (Exception ex) {
			logger.error("添加微信推广出错，" + ex);
		}

		Map<String, Object> map = new HashMap<String, Object>();
		map.put(MsgKeyContent.PAGE_AJAX_OPERATION_RESULT, result);
		map.put(MsgKeyContent.PAGE_AJAX_OPERATION_RESULT_MSG, msg);

		return map;
	}

}
